package com.xdjd.mobile.business.constant;


import com.xdjd.mobile.business.util.DateUtil;

import java.util.Date;

public class RedisConstant {

    /**
     * 验证码验证
     */
    public static final String IPHONE_SMS_CODE_REDIS = "IPHONE_SMS_CODE_REDIS";

    /**
     * 检测：同一手机号，1天不能超过5次验证码。
     */
    private final static String CHECK_TODAY_SEND_PHONE_SUM = "check_today_send_phone_sum_";

    /**
     * 检测：注册号码 ,终生只能发3次
     */
    private final static String CHECK_REG_SEND_PHONE_SUM = "check_reg_send_phone_sum_";

    /**
     * 检测：同一IP,1天不能超过20次验证码。
     */
    private final static String CHECK_IP_SEND_PHONE_SUM = "check_ip_send_phone_sum_";

    /**
     * 存储在redis map的注册手机号 的Key
     */
    public final static String IPHONE_REG_SEND_PHONE_MAP = "iphone_reg_send_phone_map";
    /**
     * 设置发送短信验证检测key值
     */
    public static String setSendPhoneNumKey(int keyType, String key) {
        StringBuilder sb = new StringBuilder();
        switch (keyType) {
            case 0:
                sb.append(CHECK_TODAY_SEND_PHONE_SUM);
                sb.append(DateUtil.date2StringByDay(new Date()));
                sb.append("_");
                break;
            case 1:
                sb.append(CHECK_IP_SEND_PHONE_SUM);
                sb.append(DateUtil.date2StringByDay(new Date()));
                sb.append("_");
                break;
            case 2:
                sb.append(CHECK_REG_SEND_PHONE_SUM);
                break;
            default:
                break;
        }
        sb.append(key);
        return sb.toString();
    }
}
